package FightingGameObject.Optimized;

/**
 * ClassName:GameText
 * Package:FightingGameObject
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/15-0:19
 * @Version:v1.0
 */
public class GameText {
    public static void main(String[] args) {
        Role r1 = new Role("孙伟晔", 100,'男');
        Role r2 = new Role("张鑫", 100,'男');
        //展示人物信息
        System.out.println("--------------");
        r1.showRoleInfo();
        System.out.println("--------------");
        r2.showRoleInfo();
        System.out.println("--------------");
        //开始格斗----回合制游戏
        int i= 1;
        while (true) {
            System.out.println("======================第"+i+"回合开始=====================");
            //r1开始攻击r2
            r1.attack(r2);
            //判断r2的剩余血量
            if (r2.getBlood() == 0) {
                System.out.println(r1.getName() + "K.O了" + r2.getName());
                break;
            }
            r2.attack(r1);
            if (r1.getBlood() == 0) {
                System.out.println(r2.getName() + "K.0了" + r1.getName());
                break;
            }
            i++;
        }
    }
}
